<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./WEB-INF/template.xhtml">

            <ui:define name="pageTitle">
                Readers
            </ui:define>

            <ui:define name="content">
                <f:view>
                    <h:form>
                        <h1><h:outputText value="Readers"/></h1>
                        <a href="reader-register.xhtml">Register reader</a>
                        <h:dataTable value="#{readerBean.readers}" var="item">
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Id"/>
                                </f:facet>
                                <h:outputText value="#{item.id}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="LastNm"/>
                                </f:facet>
                                <h:outputText value="#{item.lastNm}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="FirstNm"/>
                                </f:facet>
                                <h:outputText value="#{item.firstNm}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="MiddleNm"/>
                                </f:facet>
                                <h:outputText value="#{item.middleNm}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Tools"/>
                                </f:facet>
                                <h:link outcome="reader-edit.xhtml" styleClass="imageButton" title="Edit">
                                    <h:graphicImage url="resources/img/edit.png"/>
                                    <f:param name="id" value="#{item.id}"/>
                                </h:link>
                                <h:commandLink actionListener="#{readerBean.remove()}" styleClass="imageButton"
                                               title="Remove"
                                               onclick="return confirmRemove('#{item}');">
                                    <h:graphicImage url="resources/img/remove.png"/>
                                    <f:param name="id" value="#{item.id}"/>
                                </h:commandLink>
                            </h:column>
                        </h:dataTable>
                    </h:form>
                </f:view>

            </ui:define>

        </ui:composition>

    </body>
</html>
